package com.owen.java.demo.jave2;

import ws.schild.jave.Encoder;
import ws.schild.jave.EncoderException;
import ws.schild.jave.MultimediaObject;
import ws.schild.jave.encode.AudioAttributes;
import ws.schild.jave.encode.EncodingAttributes;
import ws.schild.jave.process.ProcessWrapper;
import ws.schild.jave.process.ffmpeg.DefaultFFMPEGLocator;

import java.io.File;
import java.io.FileOutputStream;

public class Jave2 {

    public static void main(String[] args) throws EncoderException {
//        DefaultFFMPEGLocator locator= new DefaultFFMPEGLocator();
//        String exePath= locator.getExecutablePath();
//
//        ProcessWrapper executor = locator.createExecutor();

        File source=new File("d:\\audio\\aaa.amr");
        File target=new File("d:\\audio\\aaa.mp3");

        AudioAttributes audio=new AudioAttributes();
        audio.setCodec("libmp3lame");
        audio.setBitRate(128000);
        audio.setChannels(2);
        audio.setSamplingRate(44100);

        //Encoding attributes
        EncodingAttributes attrs = new EncodingAttributes();
        attrs.setOutputFormat("mp3");
        attrs.setAudioAttributes(audio);

        Encoder encoder=new Encoder();
        encoder.encode(new MultimediaObject(source), target, attrs);

    }

}
